#include "sqlitethread.h"



//构造函数初始化
SQLiteThread::SQLiteThread(QString connectName,int num,QObject *parent):QThread(parent)
{
  //使用qRegisterMetaType对自定义类型 QList<QPoint> 进行注册
  qRegisterMetaType<QList<int>>("QList<int>");
  qRegisterMetaType<QVector<Target_Info_Table>>("QVector<Target_Info_Table>");
  dbConnect = connectName;
  groupNumber = num;

  curDate = {};
  curDateName = {};

  for(int i = 0;i < TargetNumber;i++)
    {
      vecRows.append(0);
    }
}

SQLiteThread::~SQLiteThread()
{
  sqliteTools->closeDataBase();
  delete sqliteTools;
  sqliteTools = nullptr;
}


void SQLiteThread::getGroupNumber(int msg)
{
  groupNumber = msg;
}

void SQLiteThread::getSearchDate()
{

}

//根据自定义任务重载run()函数
void SQLiteThread::run()
{

  sqliteTools = new SQLiteTools(":/autoTarget.db",dbConnect);

  sqliteTools->initDataBase();

  while(true)
    {
      curDate = {};

      curDateName = {};

      mutex.lock();

      for(int i = 1;i < TargetNumber;i++)
        {

//              curDate= sqliteTools->searchCurrentDate(groupNumber,i);

//              emit mySignal(curDate,i);

//              curDateName= sqliteTools->searchName(groupNumber);

//              emit mySignalTargetName(curDateName,i);

        }

      mutex.unlock();
      msleep(500);

    }

}
